Observe NOTAM changes instead of polling on the main actor#11
Merged
Conversation
`setupRunwayNOTAMObservation` ran a 500ms `Task { @mainactor … }` loop for
the lifetime of the takeoff/landing screen, faulting the selected
runway's NOTAM through the main `ModelContext` twice a second to detect
edits. That recurring main-thread SwiftData access contends with the
persistent store coordinator and contributes to the launch-time
`performBlockAndWait` hangs (SF50-TOLD-26/-20), which remain active on
3.5.6.
Replace the poll with `withObservationTracking` — the same Observation
mechanism the NOTAM editing views already use. The main actor now reads
the NOTAM only when it actually changes, never on a timer, and the
observation re-arms itself after each change. A generation token
invalidates the observation registered for a previous runway selection.
Refs SF50-TOLD-26, SF50-TOLD-20.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
5d1d553 to
7c024e3
Compare
RISCfuture
added a commit
that referenced
this pull request
Jun 30, 2026
Reduce the main-actor SwiftData contention behind the launch-time performBlockAndWait hangs (SF50-TOLD-26/-20), and quiet transient Sentry noise: - Stop NavDataLoaderViewModel's perpetual 0.5s state poll once nav data is loaded, so a returning user does zero background SwiftData work after launch (#10). - Observe runway NOTAM changes with withObservationTracking instead of a 500ms main-actor poll for the lifetime of the takeoff/landing screen (#11). - Treat TLS handshake failures (secureConnectionFailed) as transient and stop double-reporting weather-fetch network errors to Sentry (#9). Refs SF50-TOLD-26, SF50-TOLD-20, SF50-TOLD-2D, SF50-TOLD-21. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Removes a 500ms main-actor SwiftData poll in
BasePerformanceViewModel, part of the launch-time app hangs SF50-TOLD-26 / SF50-TOLD-20 (still active on 3.5.6: 19App Hang Fully Blockedevents on 3.5.6+47).Background
These hangs are the main thread blocked in
-[NSManagedObjectContext performBlockAndWait:].setupRunwayNOTAMObservationran aTask { @MainActor … }loop that, every 500ms for the lifetime of the takeoff/landing screen, faulted the selected runway's NOTAM through the mainModelContextto detect edits. That recurring main-thread fault contends with the persistent store coordinator and stalls the main thread under load.Change
Replace the poll with
withObservationTracking— the same Observation mechanism the NOTAM editing views already rely on:notamObservationToken) invalidates the observation registered for a previous runway selection, so stale chains from rapid runway switches bail out.Behavior is preserved: editing or clearing a NOTAM still re-initializes the model and recalculates.
Testing
swift format lint --strictandswiftlint --strictclean.SF50 TOLDscheme for the iOS 26.5 iPhone 16 simulator — succeeds.The hang reduction itself is a production/contention effect not reproducible on the simulator; this verifies the replacement preserves the recalc-on-NOTAM-change behavior.
🤖 Generated with Claude Code